function right_conditions = check_boundary_conditions_for_modes(m, CONSTS, coef, p) %[coef_right, p1_right]

    delta_min = 1e-5;
        
    for i=1:size(p,1)
        p1 = p(i);
        coef1 = coef(:,i);
        [E_rho_inside,   E_phi_inside,   E_z_inside]  = func_E_inside_check (1, m, CONSTS, coef1, p1);
        [E_rho_outside,  E_phi_outside,  E_z_outside] = func_E_outside_check(1, m, CONSTS, coef1, p1);
        [H_rho_inside,   H_phi_inside,   H_z_inside]  = func_H_inside_check (1, m, CONSTS, coef1, p1);
        [H_rho_outside,  H_phi_outside,  H_z_outside] = func_H_outside_check(1, m, CONSTS, coef1, p1);

        if(abs(imag(E_z_inside) / imag(E_z_outside) - 1) < delta_min && ...
            abs(real(H_z_inside) / real(H_z_outside) - 1) < delta_min && ...
            abs(imag(E_phi_inside) / imag(E_phi_outside) - 1) < delta_min && ...
            abs(real(H_phi_inside) / real(H_phi_outside) - 1) < delta_min && ...
            abs(imag(H_rho_inside) / imag(H_rho_outside) - 1) < delta_min)
            right_conditions(i) = true;
        else
            right_conditions(i) = false;
        end
    end

    
%     if(abs(imag(E_z_inside)) > delta_min && abs(imag(E_z_outside)) > delta_min && ...
%        abs(real(H_z_inside)) > delta_min && abs(real(H_z_outside)) > delta_min && ...
%        abs(imag(E_phi_inside)) > delta_min && abs(imag(E_phi_outside)) > delta_min && ...
%        abs(real(H_phi_inside)) > delta_min && abs(real(H_phi_outside)) > delta_min && ...
%        abs(imag(H_rho_inside)) > delta_min && abs(imag(H_rho_outside)) > delta_min)
%         right_conditions = true;
%     else
%         right_conditions = false;
%     end
    
end
